﻿@model YYS.ResultModel
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    var m = Model;
    if (m == null)
    {
        m = new YYS.ResultModel()
        {
            Icon = 0,
            Title = "提示",
            Msg = "Missing parameter"
        };
    }
    var pgTitle = !string.IsNullOrWhiteSpace(m.Title) ? m.Title : !string.IsNullOrWhiteSpace(m.Msg) ? (m.Msg.Length < 15 ? m.Msg : m.Msg.Substring(0, 15)) : "提示";
}
@if (m.IsPart != 1)
{
    <!DOCTYPE html>
    @Html.Raw("<html>")
    <head>
        <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
        <meta http-equiv="Pragma" content="no-cache" />
        <meta http-equiv="Expires" content="Thu, 01 Jan 1970 00:00:00 GMT" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black" />
        <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0" />
  
        <title>@(Html.Raw(pgTitle))</title>
    </head>
    @Html.Raw("<body>")
}

<style type="text/css">
    body { background-color: #F7F7F8; overflow: hidden; }
    .iconsize { font-size: 8em; }
</style>
<div class="box padding-15 text-center wrap h100 bg-white" style="max-width:800px; position:relative; margin:0 auto; overflow:auto;">
    <div style="overflow:hidden;">
        @if (m.Icon == 0)
        {
            <i class="ico ico-about color-blue iconsize"></i>
        }
        else if (m.Icon == 4 || m.Icon == 5)//
        {
            <i class="ico ico-about iconsize @(m.Icon == 4 ? "color-orange" : "color-red")"></i>
        }
        else if (m.Icon == 1)//loading
        {
            <i class="ico ico-loading-1 color-green anim anim-rotate anim-loop iconsize"></i>
        }
        else if (m.Icon == 2)//time
        {
            <i class="ico ico-time color-blue iconsize"></i>
        }
        else if (m.Icon == 3)//ok
        {
            <i class="ico ico-ok-circle color-green iconsize"></i>
        }
    </div>
    @if (!string.IsNullOrWhiteSpace(m.Title) || !string.IsNullOrWhiteSpace(m.Msg))
    {
        <div class="line-15 margin-top-15">
            @if (!string.IsNullOrWhiteSpace(m.Title))
            {
                <div style="color:#333;font-size:.7rem;font-weight:400;">@(Html.Raw(m.Title))</div>
            }
            @if (!string.IsNullOrWhiteSpace(m.Msg))
            {
                <div style="color: #888; margin-top: 5px; font-size: 14px;">@(Html.Raw(m.Msg))</div>
            }
        </div>
    }
    <div class="line-15 margin-top-30">
        @if (!string.IsNullOrWhiteSpace(m.AutoURL))
        {
            if (m.AutoTimeout.HasValue && m.AutoTimeout > 0)
            {
                <button id="bo" type="button" class="btn bg-gradualBlue block w100">确定（@(m.AutoTimeout)）</button>
                <script type="text/javascript">
                    (function(){
                        var s = null,bo = document.getElementById('bo'),t = @(m.AutoTimeout);
                        var o = function(){
                            bo.innerHTML='确定';
                            if(s!=null) clearInterval(s);
                            bo.disabled = true;
                            bo.classList.add('disabled');
                            @(Html.Raw("window.top.location.replace('"+m.AutoURL+"');"))
                        };
                        bo.onclick = o;
                        s = setInterval(function () {
                            t--;
                            bo.innerHTML='确定（'+t+'）';
                            if(t==0){
                                o();
                            }
                        }, 1000);
                    })();
                </script>
            }
            else
            {
                <script type="text/javascript">
                    setTimeout(function (){@(Html.Raw("window"+(m.Top==0?"": ".top") +".location.replace('"+m.AutoURL+"');"))}, 100);
                </script>
            }
        }
        else if (!string.IsNullOrWhiteSpace(m.OkButton) || !string.IsNullOrWhiteSpace(m.CancelButton))
        {
            if (!string.IsNullOrWhiteSpace(m.OkButton))
            {
                <script type="text/javascript">
                        @Html.Raw("function o(){" + (!string.IsNullOrWhiteSpace(m.OkLink) ? "window" + (m.Top == 0 ? "" : ".top") + ".location.replace('" + m.OkLink + "');" : "") + "};")
                </script>
                <button type="button" class="btn bg-gradualBlue block w100" onclick="javascript:o();">@(Html.Raw(m.OkButton))</button>
            }
            if (!string.IsNullOrWhiteSpace(m.CancelButton))
            {
                <script type="text/javascript">
                @Html.Raw("function c(){" + (!string.IsNullOrWhiteSpace(m.CancelLink) ? "window" + (m.Top == 0 ? "" : ".top") + ".location.replace('" + m.CancelLink + "');" : "") + "};")
                </script>
                <button type="button" class="btn border-gray block w100 margin-top-15" onclick="javascript:c();">@(Html.Raw(m.CancelButton))</button>
            }
        }
    </div>
    @if (!string.IsNullOrWhiteSpace(m.FootText))
    {
        <div class="box w100 color-999 margin-bottom-30 size-12">
            @(Html.Raw(m.FootText))
        </div>
    }
</div>
@if (m.IsPart != 1)
{
    @Html.Raw("</body></html>")
}
